import request from '@/utils/request'

/**
 * 注册
 * @param {*} { username, password, repassword }
 * @returns Promise
 */
export const userRegisterService = ({ username, password, repassword }) =>
  request.post('/api/reg', { username, password, repassword })

/**
 * 登录
 * @param {*} { username, password}
 * @returns Promise
 */
export const userLoginService = ({ username, password }) =>
  request.post('/api/login', { username, password })

/**
 * 获取用户的基本信息
 * @returns Promise
 */
export const userGetInfoService = () => request.get('/my/userinfo')

/**
 * 更新用户基本信息
 * @param {*} data
 * @returns
 */
export const userUpdateInfoService = (data) => request.put('/my/userinfo', data)

/**
 * 更新用户头像
 * @param {*} avatar 头像base64字符串
 * @returns
 */
export const userUploadAvatarService = (avatar) => request.patch('/my/update/avatar', { avatar })

/**
 * 修改密码
 * @param {*} params
 * @returns
 */
export const userUpdatePasswordService = (params) => request.patch('/my/updatepwd', params)
